//
//  XMGCommentHeaderView.m
//  百思不得姐
//
//  Created by Mine on 16/8/19.
//  Copyright © 2016年 Min. All rights reserved.

/**
 1.UITableViewHeaderFooterView  创建缓存池
 2.
 3.
 4.
 */

#import "XMGCommentHeaderView.h"
@interface XMGCommentHeaderView()
/** 文字标签 */
@property (weak ,nonatomic) UILabel * label;
@end


@implementation XMGCommentHeaderView

+ (instancetype)headerViewWithTableView:(UITableView*)tableView
{
    static NSString * ID = @"header";
    XMGCommentHeaderView * header = [tableView dequeueReusableHeaderFooterViewWithIdentifier:ID];
    if (header == nil) { // 缓存池中没有，自己创建
        header = [[XMGCommentHeaderView alloc]initWithReuseIdentifier:ID];
    }
    return header;
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        
        self.contentView.backgroundColor = XMGGlobalBg;
        
        // 创建label
        UILabel * label = [[UILabel alloc]init];
        label.textColor = XMGRGBColor(67, 67, 67);
        label.width = 200;
//      label.x = XMGTopicCellMargin;
#warning 以后种方式进行自适应
        label.autoresizingMask = UIViewAutoresizingFlexibleHeight;
        [self.contentView addSubview:label];
        self.label = label;
    }
    return self;
}

- (void)setTitle:(NSString *)title
{
#warning 为什么要用copy
    _title = [title copy];
    self.label.text = title;
}
@end
